package com.easy.common.utils;

import com.easy.common.constant.RegularExpression;

/**
 * 帐户 类型 检查 工具
 *
 * @author RuoYu
 * @date 2022/11/24
 */
public class AccountTypeCheckUtils {

    /**
     * 0:手机 1:邮箱 2:用户名
     *
     * @param account
     * @return {@link String}
     */
    public static int accountType(String account) {
        int type;
        boolean phone = account.matches(RegularExpression.PHONE_PATTERN);
        boolean mail = account.matches(RegularExpression.MAIL_PATTERN);
        if (phone) {
            type = 0;
        } else if (mail) {
            type = 1;
        } else {
            type = 2;
        }

        return type;
    }

    public static void main(String[] args) {
        int das = accountType("das");
        int das2 = accountType("das@163.com");
        int das3 = accountType("18777972976");
        System.out.println(das);
        System.out.println(das2);
        System.out.println(das3);
    }
}
